package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Fun {
    private int funId;
    private String funName;
    private String funLcon;
    private Collection<Functiona> functionasByFunId;

    @Id
    @Column(name = "fun_id", nullable = false)
    public int getFunId() {
        return funId;
    }

    public void setFunId(int funId) {
        this.funId = funId;
    }

    @Basic
    @Column(name = "fun_name", nullable = true, length = 30)
    public String getFunName() {
        return funName;
    }

    public void setFunName(String funName) {
        this.funName = funName;
    }

    @Basic
    @Column(name = "fun_lcon", nullable = true, length = 30)
    public String getFunLcon() {
        return funLcon;
    }

    public void setFunLcon(String funLcon) {
        this.funLcon = funLcon;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Fun fun = (Fun) o;
        return funId == fun.funId &&
                Objects.equals(funName, fun.funName) &&
                Objects.equals(funLcon, fun.funLcon);
    }

    @Override
    public int hashCode() {
        return Objects.hash(funId, funName, funLcon);
    }

    @OneToMany(mappedBy = "funByFunId")
    public Collection<Functiona> getFunctionasByFunId() {
        return functionasByFunId;
    }

    public void setFunctionasByFunId(Collection<Functiona> functionasByFunId) {
        this.functionasByFunId = functionasByFunId;
    }
}
